package edu.usc.cmb.iregulome.thread;

import java.util.ResourceBundle;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import edu.usc.cmb.iregulome.job.AnnotationDownloadJob;
import edu.usc.cmb.iregulome.job.FileDownloadJob;

/**
 * 
 * This
 * 
 * @author hsy541
 * 
 */
public class ThreadManager {

	static ExecutorService annotationDownloadService = Executors
			.newFixedThreadPool(10);

	static ExecutorService datasetDownloadService;

	private static ResourceBundle bundler = ResourceBundle.getBundle("app");

	private static int numI = 10;

	static {
		String num = bundler.getString("iregulome.sample.download.threads");
		if (num != null) {
			numI = Integer.parseInt(num);
		}
		datasetDownloadService = Executors.newFixedThreadPool(numI);

	}

	public static void startAnnotationDownloadService(int threadNo) {

		for (int i = 0; i < threadNo; i++) {
			annotationDownloadService.submit(new AnnotationDownloadJob());
		}
	}

	public static void startDatasetDownloadService() {

		for (int i = 0; i < numI; i++) {
			datasetDownloadService.submit(new FileDownloadJob());
		}
		//		
	}

}
